#pragma once

#include <wx/wxsqlite3.h>
#include "FusionSpyStruct.h"

enum DBOPENFLAG { ADMINTABLE , TUXTABLE,WLSTABLE };

class CDBWrapper
{
public:
	CDBWrapper(void);
	~CDBWrapper(void);

	int DBOpen(wxString dbname, int flag );
	int DBClose();
	void DBExist();
	
	int DBInit(wxString dbname, int flag );
	int SiteListQuery();
	int TuxAlarmListQuery( wxString sitename );
	int WlsAlarmListQuery( wxString sitename);
	
	int TuxResourceInsert( TuxResource tuxresource );
	int TuxSvrLstSave( TuxedoServerArray tuxsvrarray, wxString currenttime );
	int TuxCltLstSave( TuxedoClientArray tuxcltarray, wxString currenttime );
	int TuxQueLstSave( TuxedoQueueArray tuxquearray, wxString currenttime );

	int WlsResourceInsert( WlsResource wlsresource );
	int WlsResListQuery( wxString sqlcondition, WlsResourceArray* wlsresarray );
	int WlsSvrLstSave( WebLogicServerArray wlssvrarray, wxString currenttime );
	int WlsJvmLstSave( WebLogicJVMArray wlsjvmarray, wxString currenttime );
	int WlsThdLstSave( WebLogicThreadArray wlsthdarray, wxString currenttime );
	int WlsJDBCLstSave( WebLogicJDBCArray wlsjdbcarray, wxString currenttime );

	int TuxAlarmUpdate( TuxAlarm tuxalarm );
	int WlsAlarmUpdate( WlsAlarm tuxalarm );
	int TuxAlarmDelete( wxString sitename );
	int WlsAlarmDelete( wxString sitename );
	int ActionSetQuery( );
	int ActionSetUpdate( ActionSet actionset );
	int SiteInsert( Site site );
	int SiteDelete( Site site );
	int SysRecListInsert( SysRecList sysreclist );

	TuxAlarm getTuxAlarm();
	ActionSet getActionSet();
	WlsAlarm getWlsAlarm();
	SiteArray getAllSite();

	//Added for DBTool
	int TableExist( wxString tablename );
	wxArrayString GetRecordTimeList();
	int GetRecordNumber(wxString strbegin, wxString strend, int tabletype);
	int TuxResListQuery( wxString sqlcondition, TuxResourceArray* tuxresarray );
	int TuxCltLstQuery(wxString sqlcondition,TuxedoClientArray* tuxcltarray );
	//TuxedoClientArray* TuxCltLstQuery(wxString sqlcondition);
	TuxedoQueueArray* TuxQueLstQuery(wxString sqlcondition);
	TuxedoServerArray* TuxSvrLstQuery(wxString sqlcondition);


private:
	wxString m_dbfile;
	wxSQLite3Database  *pDatabase;
	
	SiteArray sitearray;
	TuxAlarm tuxalarm;
	WlsAlarm wlsalarm;
	ActionSet actionset;
};
